<?php


class BuildingVO
{
	public $increasing = false;
	public $increaseStartTime = 0;
	public $nextLevelTime 	= 0;
	public $name 			= "";
	public $uniqueName 		= "";
	public $id 				= 0;
	public $level 			= 0;
	public $prodMana 		= 0;
	public $prodGold 		= 0;
	public $costMana 		= 0;
	public $costGold 		= 0;
	public $costGems 		= 0;
	
	static public function buildFromConfig( $config, $uniqueName ) {
	
		$building = new BuildingVO();
		
		$levels = explode(",", $config["nextLevel"]);
		$pmana = explode(",", $config["prodMana"]);
		$pgold = explode(",", $config["prodGold"]);
		$cmana = explode(",", $config["costMana"]);
		$cgems = explode(",", $config["costGems"]);
		$cgold = explode(",", $config["costGold"]);
		
		$building->nextLevelTime 	= (int)($levels[0]);
		$building->prodMana 		= (int)($pmana[0]);
		$building->prodGold 		= (int)($pgold[0]);
		$building->costMana 		= (int)($cmana[0]);
		$building->costGems 		= (int)($cgems[0]);
		$building->costGold 		= (int)($cgold[0]);
		$building->level 			= 1;
		$building->name 			= $config["name"];
		$building->uniqueName 		= $uniqueName;
		$building->id 				= (int)($config["id"]);
		
		return $building;
	}
}

?>